package free.jsf.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestServelet extends HttpServlet{
	
	protected void traitementServelet(HttpServletRequest req, HttpServletResponse resp)
	throws ServletException, IOException  {
		
		resp.setContentType("text/html");     //la reponse de type html //important !! pour le type de flux
		PrintWriter out =  resp.getWriter();  // ouvrir un flux de sortie entre le client 
		
		out.append("<html><head><title>Premiere Page hello </title></head><body>");
		out.append("Hello JSF");
		out.append("</body></html>");
		out.close();
		
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		traitementServelet(req, resp);
		super.doGet(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		traitementServelet(req, resp);
		super.doPost(req, resp);
	}

}
